/*
 * @Description: 初始化环境配置
 * @Version: 0.0.1
 * @Autor: zhj1214
 * @Date: 2021-03-25 15:17:49
 * @LastEditors: zhj1214
 * @LastEditTime: 2021-06-08 09:46:21
 */
const fileManager = require('fs')

// const packageJson = require('./package.json')
const webpackJson = require('./webpack.config')

class envmentFile {
    constructor() {
        this.writeFile()
    }
    /**
     * @description: 写入两个配置内容
     * @author: zhj1214
     */
    writeFile() {
        // const current_ENV = TARGET.split('APPLET_ENV=')
        console.log(webpackJson)
        webpackJson.entry = './src/main.js';
        // webpackJson.output = {
        //     path: path.resolve(__dirname, './dist'),
        //     publicPath: '/dist/',
        //     filename: 'build.js'
        // }

        // packageJson['private'] = true
        // delete packageJson['main']
        


        // 把模板信息写入templates.json
        // fileManager.writeFile('./package.json', JSON.stringify(packageJson), 'utf-8', function (err) {
        //     if (err) console.error(err)
        // })

        fileManager.writeFile('./webpack.config.js', JSON.stringify(webpackJson), 'utf-8', function (err) {
            if (err) console.error(err)
        })
    }
}

new envmentFile()
